<template>
  <cfg-table
    :ref="ref"
    :config="config"
    :loading="loading"
    :data="data"
    :columns="columns"
    :additionalAction="additionalAction"
    :pageSizeOpts="pageSizeOpts"
    :pageNavigation="pageNavigation"
    :queryFormItem="queryFormItem"
    :collapseFormItem="collapseFormItem"
    :btnShowFun="btnShowFun"
    :rowbgc="rowbgc"
    :tableStyle="{overflow: 'hidden !important',}"
    @loadPage="loadPage"
    @handleEdit="handleEdit"
    @handleDelete="handleDelete"
    @handleDetail="handleDetail"
    @handleClick="handleClick"
    @handleDbClick="handleDbClick"
    @handleCreate="handleCreate"
    @handleDeleteMultiple="handleDeleteMultiple"
    @handleSearch="handleSearch"
    @handleReset="handleReset"
    @handleSelect="handleSelect"
  ></cfg-table>
</template>

<script>
export default {
  name: "pg-table",
  components: {},
  inject: ["anc"],
  data() {
    return {
      ref: "equipmentTable",
      loading: false,
      pageNavigation: {
        total: 0,
        pageSize: 10,
        pageNumber: 1,
      },
    };
  },
  props: {
    data: {
      default: () => {
        return [];
      },
    },
  },
  watch: {},
  computed: {
    config() {
      return {
        search: false,
        addButton: false,
        batchDeleteButton: false,
        downloadIcon: false,
        uploadIcon: false,
        uploadUrl: "/",
        tableSizeIcon: false,
        fullscreenIcon: false,
        refreshIcon: false,
        columnSettingIcon: false,
        action: false, // 操作
        checkColumnDisabled:false,
        additionalAction: false, // 新增自定义
      };
    },
    columns() {
      return [
        {
          key: "sf_code",
          title: "质检编码",
          minWidth: 200,
          align: "center",
          show: true,
        },
        {
          key: "sf_name",
          title: "质检名称",
          minWidth: 200,
          align: "center",
          show: true,
        },
      ];
    },
    additionalAction() {
      return {
        key: "additionalAction",
        title: "附加操作",
        slot: "additionalAction",
        width: 200,
        fixed: "right",
        align: "center",
        show: true,
        buttons: [
          {
            title: "abc",
            color: "red",
            event: (row, index) => console.log(row),
          },
          { title: "abc2", event: (row, index) => console.log(row) },
        ],
      };
    },
    pageSizeOpts() {
      return [10, 30, 50, 100];
    },
    // pageNavigation() {
    //   return { total: 0, pageSize: 10, pageNumber: 1 };
    // },
    queryFormItem() {
      return [
        {
          title: "abc1",
          key: "abc1",
          config: { type: "preText", prepend: "abc_" },
        },
        // { title: "abc2", key: "abc2", config: { type: "text" } },
        // { title: "abc3", key: "abc3", config: { type: "text" } },
        // { title: "abc4", key: "abc4", config: { type: "text" } },
        // { title: "abc5", key: "abc5", config: { type: "text" } },
        // { title: "abc6", key: "abc6", config: { type: "text" } },
        // { title: "abc7", key: "abc7", config: { type: "text" } },
        // { title: "abc", key: "any", config: { type: "select" } },
      ];
    },
    collapseFormItem() {
      return [
        // { title: "计划审核人", key: "planChecker", config: { type: "select" } },
        // { title: "质检时间", key: "time", config: { type: "dateTime" } },
        // {
        //   title: "审核状态",
        //   key: "checkStatus",
        //   config: {
        //     type: "select",
        //     options: [
        //       { label: "合格", value: "1" },
        //       { label: "不合格", value: "0" },
        //     ],
        //   },
        // },
      ];
    },
    btnShowFun() {
      return function () {
        return true;
      };
    },
    rowbgc() {
      return "red";
    },
  },
  created() {},
  mounted() {
    this.$nextTick(() => {
      this.$set(this.anc.vms, this.ref, this);
      // this.loadPage(this.pageNavigation, {});
    });
  },
  methods: {
    loadPage(pageNavigation, filter, orderBy = {}) {
      this.anc.rightLoadPage(pageNavigation, filter, orderBy);
    },
    handleEdit(row, index) {},
    handleDelete(row, index) {},
    handleDetail(row, index) {},
    handleClick(row, index) {},
    handleSelect(selection) {
      this.anc.rightSelect(selection);
    },
    handleDbClick(row, index) {},
    handleCreate() {},
    handleDeleteMultiple(selection) {
      
    },
    handleReset() {},
    handleSearch(filter) {},
    
  },
};
</script>
<style scoped></style>
